<?php

namespace app\common\service\order\order_status\items;

use app\model\CouponOrder;

/**
 * 已支付
 */
class OrderStatusPay extends OrderStatusBase
{

    //已支付查询
    public static function handle(CouponOrder $couponOrder, $next)
    {
        /**
         * 其他普通订单
         */
        if (
            in_array(
                $couponOrder->status, [
                CouponOrder::C_STATUS_RECHARGE_SUCCESS,
                CouponOrder::C_STATUS_PROCESSING,
                CouponOrder::C_STATUS_SUBMIT,
                CouponOrder::C_STATUS_NO_SUBMIT,
            ])
            &&
            $couponOrder->agent_settle_status == CouponOrder::C_AGENT_SETTLE_STATUS_NO
            &&
            $couponOrder->pay_status == CouponOrder::C_PAY_STATUS_YES

        ) {
            return $couponOrder->params['return_status'] = self::getReturnStatus(self::SUCCESS, '已支付');
        }

        return $next($couponOrder);




        /**
         * 权益订单判断
         */
//        if (
//            $couponOrder->serv_type == PRODUCT_COUPON_SERV
//            &&
//            $couponOrder->getAttr('type') == CouponOrder::TYPE_COUPON_SELF_EMPLOYED
//            &&
//            in_array($couponOrder->status, [
//                CouponOrder::C_STATUS_NO_SUBMIT,
//                CouponOrder::C_STATUS_SUBMIT,
//                CouponOrder::C_STATUS_RECHARGE_SUCCESS
//            ])
//            &&
//            $couponOrder->pay_status == CouponOrder::C_PAY_STATUS_YES
//        ) {
//            return $couponOrder->params['return_status'] = self::getReturnStatus(self::SUCCESS,'已支付'); //其实是已结算了
//        }
    }
}